import 'package:bloctest/pages/knowledge_page/knowledge_detail_page/knowledge_detail.dart';
import 'package:bloctest/pages/login_page/login_page.dart';
import 'package:flutter/material.dart';
import 'package:bloctest/pages/webview_page/web_view_page.dart';
import 'package:bloctest/pages/home_page/CameraScreen.dart';
import 'package:bloctest/pages/TabPage.dart';


class Routes {
  static Route<dynamic> generateRouter(RouteSettings settings) {
    switch (settings.name) {
      case RouterPath.tab_page:
        return pageRoute(TabPage());
      case RouterPath.web_view_page:
        return pageRoute(WebViewPages(), settings: settings);
      case RouterPath.Pic:
        return pageRoute(CustomCamera(), settings: settings);
      case RouterPath.login:
        return pageRoute(LoginPage(), settings: settings);
      case RouterPath.knowledge_detail:
        return pageRoute(KnowledgeDetailPage(), settings: settings);
    }

    return pageRoute(Scaffold(
        body: SafeArea(child: Center(child: Text("页面${settings.name}不存在")))));
  }

  /**
   * 获取MaterialPageRoute
   */
  static MaterialPageRoute pageRoute(Widget page,
      {RouteSettings? settings, bool? maintainState, bool? fullscreenDialog}) {
    return MaterialPageRoute(
        builder: (context) {
          return page;
        },
        settings: settings,
        maintainState: maintainState ?? true,
        fullscreenDialog: fullscreenDialog ?? false);
  }
}

/**
 * path路径
 */
class RouterPath {
  //主页tab
  static const String tab_page = "/tab_page";

  static const String web_view_page = "/web_view_page";

  static const String Pic = "/home_page/camera";

  static const String login = "login";

  static const String knowledge_detail = "KnowledgeDetailPage";

}
